#include "servo.h"
extern TIM_HandleTypeDef htim2;

void SetServoPWMDutyCycle(TIM_HandleTypeDef* htim, uint32_t channel, uint32_t targetPos)
{
    //if(htim->Instance == TIM2)
    //{
        if(channel == TIM_CHANNEL_1) __HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1, (uint32_t)(targetPos*CCP180Step + 500u));
        //else if(channel == TIM_CHANNEL_2) __HAL_TIM_SetCompare(htim, TIM_CHANNEL_2, (uint16_t)(targetPos*CCP180Step + 500u)); 
        else if(channel == TIM_CHANNEL_2) __HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_2, (uint32_t)(targetPos*CCP180Step + 500u)); 
        else if(channel == TIM_CHANNEL_3) __HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_3, (uint32_t)(targetPos*CCP270Step + 500u));
    //}
}

